package com.springstudy.mybatisplus.controller;

import com.springstudy.mybatisplus.api.PersonService;
import com.springstudy.mybatisplus.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * @author chenrongrong
 * @since 2020/3/6 15:27
 */
@RestController
@RequestMapping("person")
public class PersonController {

    @Autowired
    PersonService service;

    @PostMapping("get")
    public Object get(@RequestBody Person person) {
        return service.get(person.getId());
    }

    @PostMapping("idList")
    public Object idList() {
        return service.getPersonIdList();
    }

    @PostMapping("idListByParam")
    public Object idList(@RequestBody Person person) {
        return service.getPersonIdListByParam(person);
    }

    @PostMapping("getOne")
    public Object getOne(@RequestBody Person person) {
        return service.getOne(person);
    }

    @PostMapping("list")
    public Object list() {
        return service.getPersonList();
    }

    @PostMapping("unionCareerList")
    public Object unionCareerList() {
        return service.getListWithCareer();
    }

    @PostMapping("inIdList")
    public Object inIdList(@RequestBody HashMap<String, Object> map) {
        List<Long> ids = (List<Long>) map.get("ids");
        return service.getListInIds(ids);
    }

    @PostMapping("pageByPlus")
    public Object pageByPlus() {
        return service.getPageByPlus();
    }

    @PostMapping("unionList")
    public Object unionList() {
        return service.getUnionList();
    }

}
